{template header}


<div class="container">

<ol class="breadcrumb">
  <li><a href="{SITE_URL}">首页</a></li>
  <li><a href="{tsUrl('article')}">文档</a></li>
  <li class="active">发布文档  {if $groupid}
      于 {$strGroup['groupname']}
      {/if}</li>


</ol>


<div class="panel panel-default">
  <div class="panel-body">


<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">


<form id='add' method="POST" action="{SITE_URL}index.php?app=article&ac=add&ts=do"  enctype="multipart/form-data">



{if $groupid==''}
{if $arrGroup}
  <div class="form-group">
    <label>分组：</label>
    
<select id="groupid" name="groupid" class="form-control" onchange="jumptogroup('{tsUrl('article','add')}',this.options[this.options.selectedIndex].value)">
    {if $GLOBALS['TS_USER']['isadmin']=='1'}
    <option value="0">广播</option>
    {/if}
{loop $arrGroup $key $item}
<option value="{$item['groupid']}" title="{$item['notice']}" >{$item['groupname']}</option>
{/loop}
</select>
	
  </div>
    {/if}
{else}


   <input type="hidden" id="groupid" name="groupid" value="{$groupid}">
    {if $arrGroupType}
    <div class="form-group">
        <label>类型</label>

        <select id='typeid' name="typeid" class="form-control">
            <option value="0">选择类型</option>
            {loop $arrGroupType $key $item}
            <option value="{$item[typeid]}">{$item[typename]}</option>
            {/loop}
        </select>

    </div>
    {/if}

{/if}
    <div class="form-group">
        <label>标题：</label>
        <input id="title" name="title" type="text" class="form-control" placeholder="可留空，除非发外链">
    </div>
    {if $dutyid==''}
    <input type="hidden" id="dutyid" name="dutyid" value="{$dutyid}">
    {/if}

    <div class="form-group" style="display: none" id="urlform">
        <label>外链  <a class="btn btn-default" style="height: 20px;padding-top: 1px" onclick="showcontent()">切换内容</a></label>
        <input id="url" name="url" type="text" class="form-control" placeholder="填写网址，点击标题则直接跳转到该网址">
    </div>

    <div class="form-group" id="contentform">
        <label>内容{if $draft==''}<a class="btn btn-xs" href="{php echo(curPageURL())}&draft=1">恢复丢失内容</a>{/if}<a class="btn btn-default" style="height: 20px;padding-top: 1px" onclick="showurl()">切换外链</a></label>


        <div id="tseditor"></div>
        <div style="display: none;">
            <textarea id="content" name="content"></textarea>
        </div>
        <!--<textarea name="content" id="tseditor"></textarea>-->
        </div>


        <div class="form-group">
          <label>标签：</label>
          <input name="tag" id="tag" type="text" class="form-control">
        </div>



      <input type="hidden" id="token" name="token" value="{$_SESSION['token']}" />
    {if $dutyid}
    <input type="hidden" id="dutyid" name="dutyid" value="{$dutyid}" />
    {/if}
      <button class="btn btn-success" type="submit">发布文档</button>

          <a class="btn btn-default" href="{tsUrl('article')}">取消发布</a>

    <div id="setnotice" class="fr" {if $GLOBALS['TS_USER']['isadmin']=='0'}style="display: none" {/if}>
        <label>设为公告</label>
        <input name="isnotice" type="checkbox" value="1" />
    </div>

      </form>


      </div>
      <div class="col-md-2"></div>
      </div>

    </div>

      </div>
      </div>



      <script>
          $(function(){
              $('#add').on('submit', function(e) {
                  var content  = $('#content').val();
                  var url  = $('#url').val();
                  if (url==''&&content == '<p><br></p>') {
                      bootbox.alert('内容不能为空');
                      return false;
                  }
                  if (url!=''&&content != '<p><br></p>'&&content !='') {
                      bootbox.alert('内容和外链不能同时填写');
                      return false;
                  }

              });
          });

          function showurl(){
              $('#urlform').show();
              $('#contentform').hide();
          }

          function showcontent(){
              $('#urlform').hide();
              $('#contentform').show();
          }

          function showbox(content){
              if(content){
                  tsNotice(content);
              }
          }


          function showbox1(){
               {if $strGroup['notice']}
                   tsNotice("{$strGroup['notice']}");
                {/if}
           }

         function jumptogroup(url,groupid){
             window.location.href=url+'&groupid='+groupid;
         }

           window.onload = showbox1;


     </script>




{php doAction('tseditor')}
      {template footer}